package com.ss.android.newmedia.activity.browser;

import android.view.Menu;
import android.view.View;
import android.widget.PopupMenu;

import com.ss.android.newmedia.activity.browser.BrowserActivity.OperationButton;

import com.ss.android.article.browser.R;

import java.util.Iterator;

final class a implements View.OnClickListener {
    private final BrowserActivity a;

    a(BrowserActivity arg1) {
        this.a = arg1;
    }

    public final void onClick(View arg9) {
        Object v0_2;
        Iterator v4;
        Menu v3;
        PopupMenu v2;
        int v0 = arg9.getId();
        if (v0 == R.id.right_text) {
            try {
                if (this.a.d() != null) {
                    this.a.d().loadUrl("javascript:(function(){function loadScript(url,callback){var head=document.head,script;script=document.createElement(\'script\');script.async=false;script.type=\'text/javascript\';script.charset=\'utf-8\';script.src=url;head.insertBefore(script,head.firstChild);if(callback){script.addEventListener(\'load\',callback,false)}}function sendMsg(argument){var min_image_size=100;var title=\'\',desc=\'\',icon=\'\',title_ele=document.querySelector(\'title\'),desc_ele=document.querySelector(\'meta[name=description]\');if(title_ele){title=title_ele.innerText}if(desc_ele){desc=desc_ele.content}var imgs=document.querySelectorAll(\'body img\');for(var i=0;i<imgs.length;i++){var img=imgs[i];if(img.naturalWidth>min_image_size&&img.naturalHeight>min_image_size){icon=img.src;break}}window.ToutiaoJSBridge.call(\'shareInfo\',{\'title\':title,\'desc\':desc,\'image\':icon,\'url\':location.href})}if(!window.ToutiaoJSBridge){var protocol=location.protocol.indexOf(\'https\')>-1?\'https://\':\'http://\';loadScript(protocol+\'s2.pstatp.com/inapp/toutiao.js\',sendMsg)}else{sendMsg()}})();");
                }

                v2 = new PopupMenu(this.a, BrowserActivity.a(this.a));
                v3 = v2.getMenu();
                v4 = this.a.e.iterator();
                while (v4.hasNext()) {
                    v0_2 = v4.next();
                    v3.add(0, ((OperationButton) v0_2).mId, 0, ((OperationButton) v0_2).mTitleRes);
                }

                BrowserActivity v4_1 = this.a;
                v0_2 = null;
                if (v4_1.c != null) {
                    v0_2 = v4_1.c.get();
                }

                boolean v4_2 = v0_2 instanceof com.ss.android.newmedia.activity.browser.BrowserActivity.a;
                if (!v4_2) {
                    v0 = 0;
                } else if (((com.ss.android.newmedia.activity.browser.BrowserActivity.a) v0_2).d()) {
                    v0 = 1;
                } else {
                    v0 = 0;
                }
                label_42:
                if (v0 == 0) {
                    v3.removeItem(OperationButton.SHARE.mId);
                }

                v2.setOnMenuItemClickListener(this.a.f);
                if (v3.hasVisibleItems()) {
                    v2.show();
                }

                return;
            } catch (Throwable v0_1) {
                return;
            }
        }

        if (v0 == R.id.browser_back_btn) {
            this.a.onBackPressed();
            return;
        }

        if (v0 != R.id.close_all_webpage) {
            return;
        }

        this.a.onBackBtnClick();
        return;
    }
}

